<?php
    /**
     *This Only keeps record for enitities to be publish upon re-publish. 
     */
    class AutoModerationHelper extends AppModel
    {
        var $name = "AutoModerationHelper";
        var $useTable = "auto_moderation_helper";
        
        function markDependentModeration(AppModel $ParentModel,$parentId,AppModel $DependentModel,$depenentId)
        {
            $data = array(
                "parent_model"=>$ParentModel->alias,
                "parent_id" => $parentId,
                "dependent_model"=>$DependentModel->alias,
                "dependent_id"=>$depenentId
            );
            $this->create();
            $this->save(array($this->alias => $data));
        }
        function getDependents(AppModel $ParentModel,$parentId)
        {
            $dependents = $this->find("all",array("conditions"=>array("parent_model"=>$ParentModel->alias,"parent_id"=>$parentId)));
            $dependents = Set::combine($dependents,"{n}.$this->alias.id","{n}.$this->alias.dependent_id","{n}.$this->alias.dependent_model");
            return $dependents;
        }
        
        function removeMarkedDepedent(AppModel $ParentModel,$parentId)
        {
            $this->deleteAll(array("parent_model"=>$ParentModel->alias,"parent_id"=>$parentId));
        }
    }
?>